package com.huafv.flyauth.security;

import com.huafv.flyauth.core.domain.Result;
import com.huafv.flyauth.web.admin.entity.SysUser;
import com.huafv.flyauth.web.admin.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;


@RestController
@RequestMapping("/user")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping("/login")
    public Result login(SysUser sysUser){
       return loginService.login(sysUser);
    }

    @PostMapping("/logout")
    public Result logout(){
        boolean logout = loginService.logout();

        Map<String, Object> data = new HashMap<>();
        data.put("state",logout);
        System.out.println(data);
        return Result.success(data);
    }


}
